package com.bfsuol.yihang.customers.service;


import com.bfsuol.yihang.customers.api.CommandCustomerService;
import com.bfsuol.yihang.customers.domain.CustomerService;
import com.bfsuol.yihang.customers.dto.CustomerDTO;
import com.bfsuol.yihang.customers.entity.CustomerEntity;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class CommandCustomerServiceImpl implements CommandCustomerService {

    @Autowired
    private CustomerService customerService;

    @Override
    public void save(CustomerDTO customerDTO) {
        CustomerEntity customerEntity = new CustomerEntity();
        BeanUtils.copyProperties(customerDTO,customerEntity);
        customerEntity.setIsDelete(0);
        customerService.save(customerEntity);
    }

    @Override
    public void updateById(CustomerDTO customerDTO) {
        CustomerEntity customerEntity = new CustomerEntity();
        BeanUtils.copyProperties(customerDTO,customerEntity);
        customerEntity.setIsDelete(0);
        customerService.updateById(customerEntity);
    }

    @Override
    public void deleteById(Long id) {
        customerService.removeById(id);
    }
}
